﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using NUnit.Framework;
using MvcContrib.TestHelper;
using Rhino.Mocks;
using WWB.SitePointPrivateMessages.Web.Controllers;

namespace WWB.SitePointPrivateMessages.Web.Tests.Controllers.MessageImportControllerTests
{
    [TestFixture]
    public class Post_ImportMessages_with_valid_data
    {
        private ActionResult theResult;
        private MessagesController theController;
        private string returnUrl;
        private HttpPostedFileBase theFile;

        [TestFixtureSetUp]
        public void ArrangeAndAct()
        {
            theController = new MessagesController();
            Stream s = new FileStream(@"SourceData\sample.xml", FileMode.Open);
            theFile = MockRepository.GenerateStub<HttpPostedFileBase>();
            theFile.Stub(x => x.InputStream).Return(s);
            theResult = theController.ImportMessages(theFile, returnUrl);
        }

        [Test]
        public void Result_should_redirect_to_folders_list()
        {
            theResult.AssertActionRedirect().ToController("MessageView").ToAction("Folders");
        }
    }
}
